<template>
  <div>

    <ul class="comment-list">
      <li v-for="comment in sharelist" :key="comment.id" class="comment-item" @click="todetail(comment.id)">
        <div class="comment-image">
          <img :src="comment.shareimg" alt="Comment Image">
        </div>
        <div class="comment-details">
          <div class="title">{{ comment.title }}</div>
          <div class="author-time">
            <p><strong></strong> {{ comment.uname }}</p>
            <p><strong></strong> {{ comment.creattime }}</p>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>  
  import { showToast } from 'vant';
  import { getHomeShareListAPI } from "@/api/share.js";
  export default {
    data() {
      return {
        sharelist: [],
      };
    },
    created() {
      getHomeShareListAPI().then(res => { //成功回调
		console.log(res)
        this.sharelist = res.data  
		console.log(this.sharelist)
      })
    },
    methods:{
      todetail(shareid){
        this.$router.push("/sharedetail?shareid="+shareid);
      }
    }
  }
</script>

<style>
  .comment-list {
    list-style-type: none;
    padding: 0;
  }

  .comment-item {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .comment-image {
    flex: 1;
    width: 100px;
    height: 100px;
    margin-right: 10px;
  }

  .comment-image img {
    max-width: 100px;
    width: 100%;
    height: 100%;
    border-radius: 5px;
  }

  .comment-details {
    flex: 3;
    display: flex;
    flex-direction: column;
  }

  .title {
    font-size: 1.1em;
    margin-bottom: 10px;
	margin-left: 10px;
      overflow: hidden;
      text-overflow: ellipsis; /* 设置标题超出部分显示省略号 */
      /*display: -webkit-box;*/
      -webkit-line-clamp: 2; /* 控制标题行数不超过2行 */
      -webkit-box-orient: vertical;
  }

  .author-time {
    text-align:center;
    lign: right;
    margin-top: 10px;
  }

  p {
    color: #666;
    margin: 0;
  }
</style>
